﻿using B.S.Filtration.Domain;

using B.S.Filtration.Domain;
using B.S.Filtration.Domain.专检;
using B.S.Filtration.Domain.到货检验;
using B.S.Filtration.Domain.工单;
using SqlSugar;
using System.Data;

namespace B.S.Filtration.Infratrveture
{
    public class PackagedDbContext
    {
        public SqlSugarClient db { get; }

        public PackagedDbContext()
        {
            db = new SqlSugarClient(new ConnectionConfig()
            {
                DbType = SqlSugar.DbType.MySql,
                ConnectionString = "server=123.57.166.20;port=3306;user=root;password=123456;database=text;",
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute,
            });

            //db.DbMaintenance.CreateDatabase();
            //db.CodeFirst.InitTables(typeof(ProcessMonitoring));
            //db.CodeFirst.InitTables(typeof(Process));
            //db.CodeFirst.InitTables(typeof(ProcessType));
            //db.CodeFirst.InitTables(typeof(Cleaning));
            //db.CodeFirst.InitTables(typeof(Filtrate));
            //db.CodeFirst.InitTables(typeof(Power));
            //db.CodeFirst.InitTables(typeof(ProductionTask));
            //db.CodeFirst.InitTables(typeof(Feeding));
            //db.CodeFirst.InitTables(typeof(Abnormal));
            //db.CodeFirst.InitTables(typeof(Sale));
            //db.CodeFirst.InitTables(typeof(Contact));
            //db.CodeFirst.InitTables(typeof(VendorItems));
            //db.CodeFirst.InitTables(typeof(CustomerPhone));
            //db.CodeFirst.InitTables(typeof(ContactPhoneModel));


            db.CodeFirst.InitTables(typeof(Craftsmanship));
            db.CodeFirst.InitTables(typeof(CraftProcedure));

            
            db.Aop.OnLogExecuting = (sql, pars) =>
            {
                Console.WriteLine($"执行SQL:{sql},参数:{sql}");
            };
        }
    }
}
